#ifndef _Serializer_h_
#define _Serializer_h_

#include "Persistor/Persistor.h"


using namespace common;

namespace persist
{
//an object that can be made persistent in such a way that
//its data members are stored in a one by one fashion is
class Serializable;

//the mechanism that makes objects persistent so that
//their data members are stored in a one by one fashion is 
class Serializer : public Persistor
{
public:

//serializer->funnel(data)
	virtual void serialize(void *data, size_t size)=0;
	template <class T> inline Serializer& serialize(T& t) {serialize(&t, sizeof(T)); return *this;}

	virtual Serializer&    operator<<(__int64& value) {return serialize(value); }
	virtual Serializer&    operator<<(bool& value) {return serialize(value); }
	virtual Serializer&    operator<<(char& value) {return serialize(value); }
	virtual Serializer&    operator<<(int& value) {return serialize(value); }
	virtual Serializer&    operator<<(short& value) {return serialize(value); }
	virtual Serializer&    operator<<(long& value) {return serialize(value); }
	virtual Serializer&    operator<<(float& value) {return serialize(value); }
	virtual Serializer&    operator<<(double& value) {return serialize(value); }
	virtual Serializer&    operator<<(long double& value) {return serialize(value); }
	virtual Serializer&    operator<<(unsigned char& value) {return *this << (char&)value; }
	virtual Serializer&    operator<<(unsigned short& value) {return *this << (short&)value; }
	virtual Serializer&    operator<<(unsigned long& value) {return *this << (long&)value; }
	virtual Serializer&    operator<<(unsigned int& value) {return *this << (int&)value; }
	
//
	virtual Serializer&    operator<<(Serializable& s);
	
};

} //namespace

#endif